package thread.test_2;

public class Test3 {
    public static void main(String[] args) {
        // 死锁产生的
        Object objA = new Object();
        Object objB = new Object();
        new Thread(()->{
            while (true) {
                synchronized (objA) {
                    System.out.println("康A");
                    synchronized (objB) {
                        System.out.println("康B");
                    }
                }
            }
        }).start();
        new Thread(()->{
            while (true) {
                synchronized (objB) {
                    System.out.println("薇B");
                    synchronized (objA) {
                        System.out.println("薇A");
                    }
                }
            }
        }).start();
    }
}
